<?php
/*
 * @Author: your name
 * @Date: 2020-06-05 17:32:41
 * @LastEditTime: 2020-12-28 10:16:15
 * @LastEditors: Please set LastEditors
 * @Description: 安全责任人
 * @FilePath: /special/application/adminapiv3/controller/asset_manage/ManagerController.php
 */

namespace app\adminapiv3\controller\asset_manage\ministry;


use app\adminapiv3\controller\BaseController;
use app\adminapiv3\service\asset_manage\ministry\ManagerService;
use think\Request;

class ManagerController extends BaseController
{
    /**
     * @name 列表
     * @author wx
     * @date time
     */
    public function list()
    {
        $params['name'] = $this->filterInput('name', 'get');
        $params['gender'] = $this->filterInput('gender', 'get');
        $params['ministry_id'] = $this->filterInput('ministry_id', 'get');
        $params['phone'] = $this->filterInput('phone', 'get');


        $server = new ManagerService();
        $list = $server->list($params);

        return $this->jsonOutPut($list);
    }

    /**
     * @name 添加
     * @author wx
     * @date 2019/10/25 14:15
     */
    public function add(Request $request)
    {
        //接收参数
        $params = $request->only([
            'name','gender','ministry_id','phone'
        ],'post');

        $this->validate($params,'Manager.add');

        $server = new ManagerService();
        $server->add($params);

        return $this->jsonOutPut();
    }

    /**
     * @name 修改
     * @author wx
     * @date 2019/10/25 14:16
     */
    public function modify(Request $request)
    {
        $params = $request->only([
            'id','name','gender','ministry_id','phone'
        ],'post');
        $this->validate($params,'Manager.modify');


        $server = new ManagerService();
        $server->modify($params['id'], $params);


        return $this->jsonOutPut();
    }

    /**
     * @name 删除
     * @author wx
     * @date time
     */
    public function del(Request $request)
    {
        $params = $request->only([
            'id'
        ],'post');
        $this->validate($params,'Manager.del');


        $server = new ManagerService();
        $server->del($params['id']);

        return $this->jsonOutPut();
    }
}